home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozlib15.zoo / sozdistr / include / xdlibs / minimum.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-03  |  1.5 KB  |  75 lines

  1. /*
  2.  *
  3.  * DO NOT INCLUDE THIS FILE IF YOU USE ARGC/ARGV OR STANDARD I/O AT ALL!!
  4.  *
  5.  * This header file defines a _main() function, that replace
  6.  * the one in the standard library.  With this functions, none of the
  7.  * standard i/o functions normally linked into a program will be referenced,
  8.  * and the variables like _mint or _starttime are not set.
  9.  *
  10.  * However... if you REALLY need arguments, but still want a teeny tiny
  11.  * (non-portable) program, you can use a getcmdln() like the one in here.
  12.  */
  13.  
  14. #ifndef _MINI_H
  15. #define    _MINI_H
  16. #pragma echo warning from minimum.h 
  17. #pragma echo never use this file unless you have very good reasons
  18.  
  19. extern int    _argc;
  20. extern char    **_argv;
  21. extern char    *_envp;
  22.  
  23. extern void _exit(int status);
  24.  
  25. _main()
  26. {
  27.     _exit(main(_argc, _argv, _envp));
  28. }
  29.  
  30. #define    exit(code)    _exit(code)    /* no stdio, no cleanup needed */
  31.  
  32.  
  33. #if 0
  34.     /* this is just an example, so it is commented out by
  35.      * the precompiler
  36.      */
  37.  
  38. void getcmdln()
  39. {
  40.     register char *p, *q, *t;
  41.     char    *cmdline;
  42.     int        cmdlen;
  43.  
  44. #ifndef _BASEP_H
  45.     extern char *_base;
  46.     cmdline = _base+0x80;
  47. #else
  48.     cmdline = _base->p_cmdlin;
  49. #endif
  50.     cmdlen = *cmdline++;
  51.  
  52.     /* this was how to get a pointer to cmdline
  53.      * the following is just an example, you may use strtok() as well.
  54.      */
  55.  
  56.     p = cmdline;
  57.     t = (p + cmdlen);
  58.     *t = '\0';
  59.  
  60.     while(p < t) {
  61.         while(*p == ' ')
  62.             ++p;
  63.         if(*p == '\0')
  64.             break;
  65.         for(q = p; (*q && (*q != ' ')); ++q);
  66.         *q = '\0';
  67.         process(p);    /* <-- insert real operation here */
  68.         p = q + 1;
  69.     }
  70. }
  71.  
  72. #endif
  73.  
  74. #endif
  75.